<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

$errors = array();

if ($route->POST('action') == 'add')
{
	$name = $route->POST('name');
	$name_rod = $route->POST('name_rod');
	$name_pred = $route->POST('name_pred');
	$path = $route->POST('path');
	$phone_code = $route->POST('phone_code');
	$country = $route->POST('country');
	
	$query = "insert into `city` values(NULL,'$name','$path','$name_rod','$name_pred','$phone_code','$country')";
	
	if ($db->sendQuery($query))
		goToPage("/admin/city/edit/".mysql_insert_id());
}

require_once ADMIN.DS."/head.php";
?>

<h1>Добавление города</h1><br /><?php
	if (count($errors) > 0)
		echo "<p class='fail'>".implode("<br />",$errors)."<br /><br /></p>";
?>
<form method='POST'>
	<input type='hidden' name='action' value='add' />
	<table cellpadding='3' cellspacing='5'>
		<tr>
			<td width='170px'>Название</td>
			<td width='300px'><input type='text' name='name' value='<?php echo $route->POST("name"); ?>' /></td>
		</tr>
		<tr>
			<td>Название в род. падеже</td>
			<td><input type='text' name='name_rod' value='<?php echo $route->POST("name_rod"); ?>' /></td>
		</tr>
		<tr>
			<td>Название в пред. падеже</td>
			<td><input type='text' name='name_pred' value='<?php echo $route->POST("name_pred"); ?>' /></td>
		</tr>
		<tr>
			<td>Путь</td>
			<td><input type='text' name='path' value='<?php echo $route->POST("path"); ?>' /></td>
		</tr>
		<tr>
			<td>Телефонный код</td>
			<td><input type='text' name='phone_code' value='<?php echo $route->POST("phone_code"); ?>' /></td>
		</tr>
		<tr>
			<td>Страна</td>
			<td>
				<select name='country'>
					<option value='1'>Россия</option>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan='2' align='right'><input type='submit' value='Добавить' /></td>
		</tr>
	</table>
</form>

<?php require_once ADMIN.DS."footer.php"; ?>